#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <qprocess.h>
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //连接信号与槽 谁发出信号 发出什么信号 谁处理信号 怎么处理
    connect(ui->ConfirmButton,SIGNAL(returnPressed()),this,SLOT(on_ConfirmButton_clicked()));

    connect(ui->CancelButton,&QPushButton::clicked,this,&MainWindow::on_CancelButton_clicked);

    connect(ui->BrowseButton,&QPushButton::clicked,[this]()
    {
        QMessageBox::information(this,"提示信息","点击了浏览");
    });

}

MainWindow::~MainWindow()
{
    delete ui;   
}


void MainWindow::on_ConfirmButton_clicked()
{
    //获取lineedit数据
    QString program = ui->CmdLineEdit->text();
    QMessageBox::information(this,"提示","点击了确认");

    //创建Process  对象
    QProcess *myProcess = new QProcess(this);
    myProcess->start(program);

}


void MainWindow::on_CancelButton_clicked()
{
    this->close();
}

